package com.wolf.client;

import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.FactoryBean;

/**
 * @auth: dylan
 * @Desc:
 * @Time: 2024/5/3
 */
public class WolfDynamicFactoryBean implements FactoryBean<Object> {

    private Object  object;

    @Getter
    private String host;

    @Getter
    private int  port;

    @Getter
    private Class<?> interfaceClass;

    public void setHost(String host) {
        this.host = host;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public void setInterfaceClass(Class<?> interfaceClass) {
        this.interfaceClass = interfaceClass;
    }

    @Override
    public Object getObject() throws Exception {
        return object;
    }

    @Override
    public Class<?> getObjectType() {
        return interfaceClass;
    }

    public void init(){
        this.object=WolfClientProxy.proxy(this.interfaceClass,this.host,this.port);
    }

}
